
let JsonConfigFile = require('../utils/JsonConfigFile.js');

let defaultConfig = {
    "CONFIG": "此为Websocket协调服务端配置文件",
    "Websocket": {
        "ServerName": "WS协调服务端", // WS协调服务端名称
        "Port": 9001,                // WS协调服务端端口
        "ConnectKey": "FlySteve",    // WS协调服务端连接密钥
        "HeartBeatInterval": 10000,  // WS协调服务端心跳间隔
        "HeartBeatTimeoutCount": 2,  // WS协调服务端心跳超时次数，2次无回应断开连接
        "Debug": false,
    },
    "Chat": {
        "ConsoleDisplay": true,                       // WS协调服务端控制台聊天显示
        "ChatLog": true,                           // 聊天日志, 记录所有玩家聊天日志到./log/chatwss/PlayerChat/
        "ChatHeader": "",                          // 聊天前缀, 玩家在聊天内容开头添加此字符进行云端聊天。
        "TipHeader": "§d『§b${ServerName}§d』§r",  // 聊天显示头衔, ${ServerName} 替换为WS协调服务端名称。
    },
    // "MapDrawing":{
    //     "ImgFilePath": "./plugins/CustomGetMap/.img"   // CustomGetMap图片库路径 ./plugins/CustomMap/.img
    // }
};

let RUNMODE;
try {
    if (mc != undefined){
        RUNMODE = 'LSE';
    }
}
catch(e){
    RUNMODE = 'NODEJS';
}

if (RUNMODE == 'LSE'){
    global.CONF = {
        CONFIG: new JsonConfigFile('./plugins/CoordinationWss/data/WSServerConfig.json', JSON.stringify(defaultConfig)),
        PLAYERSYNCTEMP: new JsonConfigFile('./plugins/CoordinationWss/data/playerSyncTemp.json'),
    };
}else{
    global.CONF = {
        CONFIG: new JsonConfigFile('./data/WSServerConfig.json', JSON.stringify(defaultConfig)),
        PLAYERSYNCTEMP: new JsonConfigFile('./data/playerSyncTemp.json'),
    };
}

if (RUNMODE == 'NODEJS'){
    global.VERSION = JSON.parse(new JsonConfigFile('./manifest.json').read()).version.split('.').map(n=>Number(n));
}else{
    global.VERSION = JSON.parse(File.readFrom('./plugins/CoordinationWss/manifest.json')).version.split('.').map(n=>Number(n));
}